#! /bin/sh

CSS=`cat << 'EOF'
<link rel="stylesheet" href="tovid_style.css" type="text\/css">
EOF`

ALTCSS=`cat << 'EOF'
  <link rel="stylesheet" href="tovid_style.css" media="screen" type="text/css" title="Default">
  <link rel="stylesheet" href="tovid_print.css" media="print" type="text/css">
  <link rel="alternate stylesheet" href="tovid_print.css" media="screen" title="Printer-friendly">
EOF`

NAVMENU=`cat << 'EOF'
  <ul id="navmenu">
    <li><a href="toc.html">Site map</a></li>

    <li><a href="http://sourceforge.net/projects/tovid">Get tovid</a></li>

    <li class="menuparent">
      <a href="#">Help</a>

      <ul>
        <li><a href="howto.html">howto</a></li>
        <li><a href="faq.html">FAQ</a></li>
        <li><a href="irc://irc.freenode.net/tovid">IRC channel</a></li>
        <li><a href="http://www.createphpbb.com/phpbb/tovid.html">forum</a></li>
        <li><a href="http://lists.sourceforge.net/lists/listinfo/tovid-users">user mailing list</a></li>
      </ul>
    </li>

    <li class="menuparent">
      <a href="manpages.html">Manpages</a>
      <ul>
        <li><a href="tovid.html">tovid</a></li>
        <li><a href="idvid.html">idvid</a></li>
        <li><a href="makemenu.html">makemenu</a></li>
        <li><a href="makexml.html">makexml</a></li>
        <li><a href="makedvd.html">makedvd</a></li>
        <li><a href="postproc.html">postproc</a></li>
        <li><a href="dvrequant.html">dvrequant</a></li>
      </ul>
    </li>

    <li class="menuparent">
      <a href="#">Language</a>
      <ul>
        <li><a href="fr/">Français</a></li>
        <li><a href="es/">Español</a></li>
      </ul>
    </li>

  </ul>
EOF`

# Replace css with altcss in all HTML files

FILES="*.html"
for FILE in $FILES; do
    head -n 10 $FILE > $FILE.tmp
    echo $"$ALTCSS" >> $FILE.tmp
    cat $FILE | sed -n '12,/alink[^>]*\>/p' >> $FILE.tmp
    echo $"$NAVMENU" >> $FILE.tmp
    cat $FILE | sed -n '/div class="navheader"/,$p' >> $FILE.tmp
    mv -v $FILE.tmp $FILE
done

